﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <link rel="stylesheet" href="../../Scripts/zTree/css/demo.css" type="text/css" />
    <link rel="stylesheet" href="../../Scripts/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css" />

    <script type="text/javascript" src="../../Scripts/zTree/js/jquery-1.4.4.min.js"></script>

    <script type="text/javascript" src="../../Scripts/zTree/js/jquery.ztree.core-3.0.js"></script>

    <script type="text/javascript" src="../../Scripts/zTree/js/jquery.ztree.excheck-3.0.js"></script>

    <script type="text/javascript">
        var setting = {
            check: {
                enable: true,
                chkStyle: "checkbox",
                chkboxType: { "Y": "s", "N": "s" }
            },
            callback: {
                onCheck: totalClr
            }
        };
        
        var zNodes = <%=ViewData["treedefi"] %>;       
		
        $(function() {
      		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			$("#treeDemo").hide();
			
            $("#steplist").change(function IntityTree() {
                var taskname = $(this).val();
                //var taskname = $("#steplist option:selected").val();
                var taskdes = $("#steplist option:selected").text();
                $("#task_des").attr("value", taskdes);
                var guid = $("#txtGUID").val();
                $.ajax({
                    type: "POST",
                    url: "/WorkFlow/InityTree",
                    data: "taskname=" + taskname + "&guid=" + guid,
                    success: function(res) {
                        if (res != "[]") {
                            $("#treeDemo").show();   
                        }
                        else {
                            //alert(res.toString());
                            $("#treeDemo").hide();
                        }
                    }
                });
            }
        )
        })

        //统计tree上选中的人员，将其组成一个字符串数组存放在 id=selectarr 隐藏标签中
        function totalClr(event, treeId, treeNode) {
            //alert(treeNode.id + ", " + treeNode.name + "," + treeNode.checked);
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = treeObj.getCheckedNodes(true);
            
            var temp = "";
            for (i = 0; i < nodes.length; i++) {
                temp = temp + nodes[i].id + ",";
            }
            $("#selectarr").attr("value", temp);
        };
        
        function OnSubmit()
        {
             //如果显示，则必须选择一个处理人
             if($("#treeDemo").is(":visible") && $("#selectarr").val()=="")
            {
                alert("最少选择一个处理人！");
                return false;
            }
            return true;
        }
        
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <div id="m">
            <%using (Html.BeginForm("WFProcessManage", "WorkFlow"))
              { %>
            <input type="submit" value="确定" onclick="return OnSubmit()" />
            <div id="div_bdinfo">
                流程号：<%=Html.TextBox("txtGUID", ViewData["uniqueid"])%><br />
                审批意见：<%=Html.DropDownList("steplist","=选择=")%>
            </div>
            <div id="div_hidenvalue">
                <%=Html.Hidden("form_id",ViewData["form_id"])  %>
                <%=Html.Hidden("task_id", ViewData["task_id"])%>
                <%=Html.Hidden("ptask_id", ViewData["ptask_id"])%>
                <%=Html.Hidden("task_name")  %>
                <%=Html.Hidden("task_des")%>
                <%=Html.Hidden("selectarr", ViewData["clrs"])%>
            </div>
            <div id="div_bd" style="position: relative; width: 80%; height: 750px; border: solid 1px;">
                <% Response.Write(ViewData["formdefi"]); %>
            </div>
            <div id="div_tree" class="zTreeDemoBackground left">
                <ul id="treeDemo" class="ztree">
                </ul>
            </div>
            <%} %>
        </div>
    </div>
</asp:Content>
